package com.example.backend.service.impl;

import com.example.backend.entity.ShenFen;
import com.example.backend.mapper.ShenFenMapper;
import com.example.backend.service.IShenFenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShenFenService implements IShenFenService {
    @Autowired
    private ShenFenMapper shenFenMapper;
    @Override
    public boolean addShenFen(ShenFen shenFen) {
        return shenFenMapper.insert(shenFen) > 0;
    }

    @Override
    public boolean deleteShenFen(Integer yhid) {
        return shenFenMapper.deleteById(yhid) > 0;
    }

    @Override
    public boolean updateShenFen(ShenFen shenFen) {
        return shenFenMapper.updateById(shenFen) > 0;
    }

    @Override
    public List<ShenFen> queryShenFen() {
        return shenFenMapper.selectList(null);
    }

    @Override
    public ShenFen queryShenFenById(Integer yhid) {
        return shenFenMapper.selectById(yhid);
    }

    @Override
    public ShenFen queryShenFenByYhzh(ShenFen shenFen) {
        return shenFenMapper.loginShenFen(shenFen);
    }


    /**
     * 充值
     **/
    @Override
    public boolean recharge(Integer yhid, Double amount) {
      return shenFenMapper.recharge(yhid, amount);
    }

    @Override
    public boolean forgotPwd(ShenFen shenFen) {
        return shenFenMapper.forgotPwd(shenFen.getYhzh(), shenFen.getPwd());
    }
}
